import Vue from 'vue'
import VueRouter from 'vue-router'
import NProgress from 'nprogress' 
import 'nprogress/nprogress.css'// nprogress样式文件
Vue.use(VueRouter)

const routes = [
  // 首页
  {
    path: '/',
    name: 'home',
    component: () => import(/* webpackChunkName: "about" */ '../views/indexViews/index.vue')
  },
  {
    path: '/index',
    name: 'index',
    component: () => import(/* webpackChunkName: "about" */ '../views/indexViews/index.vue')
  },
  // 注册页面
  {
    path: '/register',
    name: 'register',
    component: () => import(/* webpackChunkName: "about" */ '../views/registerViews/index.vue')
  },
  // 登录页面
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "about" */ '../views/loginViews/index.vue')

  },
  //加载中页面
  {
    path: '/loading',
    name: 'loading',
    component: () => import(/* webpackChunkName: "about" */ '../views/loadViews/index.vue')
  },
  // 字段补全页面
  {
    path: '/complete',
    name: 'complete',
    component: () => import(/* webpackChunkName: "about" */ '../views/completeViews/index.vue')
  },
  // 搜索详情页面
  {
    path: '/search',    
    name: 'search',
    component: () => import(/* webpackChunkName: "about" */ '../views/searchViews/index.vue')
  },
  // 播放界面
  {
    path: '/play',
    name: 'play',
    component: () => import(/* webpackChunkName: "about" */ '../views/playViews/index.vue')
  },
  // 浏览历史
  {
    path: '/history',
    name: 'history',
    component: () => import(/* webpackChunkName: "about" */ '../views/historyViews/index.vue')
  },
  // 收藏
  {
    path: '/collect',
    name: 'collect',
    component: () => import(/* webpackChunkName: "about" */ '../views/collectViews/index.vue')
  },
  //智能引导
  {
    path: '/guide',
    name: 'guide',
    component: () => import(/* webpackChunkName: "about" */ '../views/guideViews/index.vue')
  },
  // 上传资源
  {
    path: '/upload',
    name: 'upload',
    component: () => import(/* webpackChunkName: "about" */ '../views/uploadViews/index.vue')
  },
  //我的课程
  {
    path: '/mycourse',
    name: 'mycourse',
    component: () => import(/* webpackChunkName: "about" */ '../views/myUploadCourseViews/index.vue')
  },
  // 404页面
  {
    path: '*',
    name: '404',
    component: () => import(/* webpackChunkName: "about" */ '../components/404.vue')
  },
  {
    path: '/profile',
    name: 'mycourse',
    component: () => import(/* webpackChunkName: "about" */ '../views/profileViews/index.vue')
  },
  {
    path: '/community',
    name: 'community',
    component: () => import(/* webpackChunkName: "about" */ '../views/communityViews/index.vue')
  },
  {
    path: '/chat',
    name: 'Chat',
    component: () => import('../views/chatViews/index.vue') // 假设你有这个组件
  }
  
]

const router = new VueRouter({
  mode: 'history',
  routes
})
//当路由开始跳转时 路由进度条
router.beforeEach((to, from , next) => {
  // 开启进度条
  NProgress.start();

    next();
  
});
//当路由跳转结束后
router.afterEach(() => {  
  // 关闭进度条
  NProgress.done()
})
export default router
